import formatColumn from 'packages/BaseTableCell/formatColumn';
import i18n from '@src/locales';
import { getThemeColor } from '@src/util/business/color'

// 列表 && 选择列
export const getColumnFields = () => {
  return [
    {
      fieldName: 'contractStatus',
      displayName:  i18n.t('common.fields.contractStatus.displayName'),
      formType: 'select',
      isSearch: 0,
    },
    {
      fieldName: 'creater',
      displayName:  i18n.t('common.fields.createUser.displayName'),
      formType: 'user',
      isSearch: 1,
    },
    {
      fieldName: 'createTime',
      displayName:  i18n.t('common.fields.createTime.displayName'),
      formType: 'datetime',
      isSearch: 1,
    },
    {
      fieldName: 'updateTime',
      displayName: i18n.t('common.fields.updateTime.displayName'),
      formType: 'datetime',
      isSearch: 1,
    },
  ].map(item => {
    // 初始化属性
    let field = {
      ...item,
      setting: item.setting || {},
      isSystem: 1,
      isNull: 1,
      orderId: 1,
      show: true,
      tableName: 'contract',
      minWidth: 150,
      visable: typeof item.visable == 'undefined' ? true : item.visable,
    };
    return formatColumn(field);
  });
};

// 高级搜索
export const getAdvancedFields = () => {
  return [
    {
      fieldName: 'contractStatus',
      displayName: i18n.t('common.fields.contractStatus.displayName'),
      field: 'contractStatus',
    },
    {
      fieldName: 'createUid',
      displayName: i18n.t('common.fields.createUser.displayName'),
      field: 'createUid',
    },
    {
      fieldName: 'createTime',
      displayName: i18n.t('common.fields.createTime.displayName'),
      field: 'createTime',
    },
    {
      fieldName: 'updateTime',
      displayName: i18n.t('common.fields.updateTime.displayName'),
      field: 'updateTime',
    },
  ].map(item => {
    return {
      ...item,
      setting: item.setting || {},
      defaultValue: null,
      show: true,
      isNull: 1,
      isSystem: 1,
      orderId: 0,
    };
  });
};

// 数据状态
export const dataStatusTabList = () => {
  return [
    {
      id: '1',
      name: i18n.t('common.base.all'),
      type: 'total',
      enName: '',
    },
    // {
    //   id: '2',
    //   name: i18n.t('contract.contractStatus.APPROVAL'),
    //   type: 'wait',
    //   enName: 'APPROVAL',
    // },
    {
      id: '3',
      name: i18n.t('contract.contractStatus.EFFECTIVE'),
      type: 'effect',
      enName: 'EFFECTIVE',
    },
    {
      id: '4',
      name: i18n.t('contract.contractStatus.WAIT'),
      type: 'wait',
      enName: 'WAIT',
    },
    {
      id: '5',
      name: i18n.t('contract.contractStatus.CLOSED'),
      type: 'closed',
      enName: 'CLOSED',
    },
    {
      id: '6',
      name: i18n.t('contract.contractStatus.EXPIRED'),
      type: 'expired',
      enName: 'EXPIRED',
    },
    // {
    //   id: '6',
    //   name: '已拒绝',
    //   type: 'refuse',
    // },
    {
      id: '7',
      name: i18n.t('contract.contractStatus.DRAFT'),
      type: 'draft',
      enName: 'DRAFT',
    },
  ];
};

// 创建视角
export const createViewTabList = () => {
  return [
    {
      id: '1',
      name: i18n.t('common.base.all'),
      enName: '',
    },
    {
      id: '2',
      name: i18n.t('contract.list.iCreated'),
      enName: 'CREATE',
    },
  ];
};

// 产品客户合同附加组件默认表头显示
export const getCustomerOrProductFields = () => {
  return [
    {
      displayName: i18n.t('common.fields.contractNo.displayName'),
      fieldName: 'contractNo',
      formType: 'text',
      show: true,
    },
    {
      displayName: i18n.t('common.fields.contractName.displayName'),
      fieldName: 'contractName',
      formType: 'text',
      show: true,
    },
    {
      fieldName: 'contractStatus',
      displayName: i18n.t('common.fields.contractStatus.displayName'),
      formType: 'select',
      show: false,
    },
    {
      fieldName: 'creater',
      displayName: i18n.t('common.fields.createUser.displayName'),
      formType: 'user',
      show: true,
    },
    {
      fieldName: 'createTime',
      displayName: i18n.t('common.fields.createTime.displayName'),
      formType: 'datetime',
      show: true,
    },
    {
      fieldName: 'updateTime',
      displayName: i18n.t('common.fields.updateTime.displayName'),
      formType: 'datetime',
      show: true,
    },
  ].map(item => {
    // 初始化属性
    let field = {
      ...item,
      setting: item.setting || {},
      isSystem: 1,
      isNull: 1,
      orderId: 1,
      tableName: 'contract',
      minWidth: 150,
      visable: typeof item.visable == 'undefined' ? true : item.visable,
      sortable: false,
    };
    return {
      ...field,
    };
  });
};

export const getStatusValue = {
  APPROVAL: i18n.t('contract.contractStatus.APPROVAL'),
  EFFECTIVE: i18n.t('contract.contractStatus.EFFECTIVE'),
  WAIT: i18n.t('contract.contractStatus.WAIT'),
  CLOSED: i18n.t('contract.contractStatus.CLOSED'),
  EXPIRED: i18n.t('contract.contractStatus.EXPIRED'),
  DRAFT: i18n.t('contract.contractStatus.DRAFT'),
};

export const contractStatusBgc = {
  APPROVAL: '#448AFF',
  EFFECTIVE: getThemeColor(),
  WAIT: '#595959',
  CLOSED: '#595959',
  EXPIRED: '#595959',
  DRAFT: '#595959',
}

export const options = [{
  value: 'AFTER_CONTRACT_CREATE',
  label: i18n.t('contract.setting.contractAdvancedSettings.contractCreate')
},
{
  value: 'AFTER_CONTRACT_EFFECT',
  label: i18n.t('contract.setting.contractAdvancedSettings.contractEffect')
}]